package com.smarttest.portal.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smarttest.portal.service.timertask.util.OutboxDaoDxt;

@Controller
public class AlarmController {
	private static final Logger log = Logger.getLogger(AlarmController.class);
//	 @RequestMapping("/alarm/{type}.action",method = RequestMethod.GET)
	@RequestMapping(value = "/alarm/{type}.action", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=utf-8")
	 @ResponseBody
	 public String getTestById(@PathVariable String type,HttpServletRequest req){
		log.debug("/alarm/{type}.action:"+req.getPathInfo()+",req:"+req.getParameterMap());
		 if(StringUtils.isEmpty(type)){
			 type = "dingtalk"; 
		 }
		 String phones = req.getParameter("phones");
			String msg = req.getParameter("msg");
		 
		 
		 OutboxDaoDxt daoDxt = new OutboxDaoDxt();
		 return daoDxt.insert(10, phones, msg, null, type);
	 }
	public static void main(String[] args) {
		OutboxDaoDxt daoDxt = new OutboxDaoDxt();
		daoDxt.insert(10, "13408517677",
				"运营平台-接口监控：method:\nmsg：", null,
				"dingtalk");
	}
}
